package com.cg.service.Impl;

import com.cg.entity.User;
import com.cg.mapper.UserMapper;
import com.cg.service.UserService;
import com.cg.util.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User login(String username,String password) {
        password= Md5Util.getMD5String(password);
        return userMapper.login(username,password);
    }

    //根据用户名查询
    @Override
    public User findByUsername(String username) {
        return userMapper.findByUsername(username);
    }

    //添加账号
    @Override
    public void addUser(User user) {
//        user.setName(user.getName());
//        user.setUsername(user.getUsername());
        user.setPassword(Md5Util.getMD5String(user.getPassword()));
        userMapper.addUser(user);
    }

}
